/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package guiutilities;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import org.jdesktop.application.ResourceMap;

/**
 *
 * @author tommy
 */
public class jSliderDialog extends JDialog {
	private  javax.swing.JSlider jThresholdSlider;
	private JButton jConfirmButton;
	private JLabel jThresholdLabel;
	private double threshold;
	
	public jSliderDialog(JFrame parent, ResourceMap resourceMap) {
		super(parent,resourceMap.getString("jSliderDialog.title"), true);
        setAlwaysOnTop(true);
        setName("jSliderDialog"); // NOI18N
        setResizable(false);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setPreferredSize(new Dimension(512,196));
		setMaximumSize(new Dimension(512,196));
		setResizable(false);
		setSize(512, 196);

		jThresholdSlider = new javax.swing.JSlider();
        jConfirmButton = new javax.swing.JButton();
        jThresholdLabel = new javax.swing.JLabel();
		
        jThresholdSlider.setMaximum(255);
        jThresholdSlider.setName("jThresholdSlider"); // NOI18N

        jConfirmButton.setText(resourceMap.getString("jConfirmButton.text")); // NOI18N
        jConfirmButton.setName("jConfirmButton"); // NOI18N

        jThresholdLabel.setText(resourceMap.getString("jThresholdLabel.text")); // NOI18N
        jThresholdLabel.setName("jThresholdLabel"); // NOI18N

        javax.swing.GroupLayout jSliderDialogLayout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(jSliderDialogLayout);
        jSliderDialogLayout.setHorizontalGroup(
            jSliderDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jSliderDialogLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jSliderDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jConfirmButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jThresholdLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(28, 28, 28)
                .addComponent(jThresholdSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );
        jSliderDialogLayout.setVerticalGroup(
            jSliderDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jSliderDialogLayout.createSequentialGroup()
                .addContainerGap(26, Short.MAX_VALUE)
                .addComponent(jThresholdLabel)
                .addGap(18, 18, 18)
                .addComponent(jConfirmButton)
                .addGap(15, 15, 15))
            .addGroup(jSliderDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jThresholdSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(49, Short.MAX_VALUE))
        );
		
		jConfirmButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jConfirmButtonActionPerformed(evt);
            }
        });
	}
	
	private void jConfirmButtonActionPerformed(ActionEvent evt) {
		this.threshold = jThresholdSlider.getValue();
		this.dispose();
	}
	
	public double getSliderValue() {
		return this.threshold;
	}
}
